const http = require('axios');
class PushTest {
	constructor(arg) {
		this.url = "http://148.70.60.178:3001/mobile-push/v1/UniBaseFrame"
	}

	static init() {
		return new this();
	}

	async start() {
		let ret = await pushTest.testPushSystemMessage();
		console.log(ret.data);
	}

	async testPushUserMessage() {
		let msgData = {
			sender: 'e9ca23d68d884d4ebb19d07889727dae',
			targetAlias: ['493bd8eb820f460fb9979f0a488fd5c0'],
			preload: {
				"type": 10,
				"label": 21,
				"text": "这是一个测试内容"
			}
		};
		let postData = {
			msgData: JSON.stringify(msgData)
		};
		return await http.post(this.baseApi + "/msg/sendUserMsg", postData);
	};


	/**
	 * 测试推送系统消息
	 */
	async testPushSystemMessage() {
		let msgData = {
			targets: 'e9ca23d68d884d4ebb19d07889727dae',
			type: 13, //11.工作代办 12:通知公告 13:系统消息
			label: '',
			
			title: '这是一个测试消息',
			content: '这是消息的内容这是消息的',
			msgId: '111'
		};
		let postData = {
			msgData: JSON.stringify(msgData)
		};
		return await http.post(this.url + '/msg/sendSystemMsg', postData);

	}
}

// let pushTest = PushTest.init();
// pushTest.start();

setTimeout(()=>{
	console.log(4);
},0);
new Promise((a,b)=>{
	console.log(1);
	for(let i=0;i<10000;i++){
		i==9999 && a();
	}
	console.log(2);
}).then(()=>{
	console.log(5);
});
console.log(3);
